package com.appspot.aliga.presentation;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.appspot.aliga.League;
import com.appspot.aliga.R;

public class StartView extends Activity {
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.start_view);
		
		// Buttons
		Button league1But = (Button) this.findViewById(R.id.league1_but);
		league1But.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				showLeagueView(view, League.Bundesliga_1_2010.getId());
			}
		});
		
		Button league2But = (Button) this.findViewById(R.id.league2_but);
		league2But.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				showLeagueView(view, League.Bundesliga_2_2010.getId());
			}
		});
		
		Button league3But = (Button) this.findViewById(R.id.league3_but);
		league3But.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				showLeagueView(view, League.Bundesliga_3_2010.getId());
			}
		});
	}

	private void showLeagueView(View view, int leagueID) {
		Bundle bundle = new Bundle();
		bundle.putInt(AppKeys.KEY_LEAGUE_ID, leagueID);
		Intent showLeagueView = new Intent(view.getContext(), LeagueView.class);
		showLeagueView.putExtras(bundle);
		startActivityForResult(showLeagueView, 0);
	}
}
